import api from "@/api";
export default {
  //解决命名空间冲突
  namespaced: true,
  state: {
    classes: [],
    total: 0,
  },
  mutations: {
    SET_CLASSES(state, payload) {
        state.classes = payload.rows;
        state.total = payload.total;
       
      },
  },
 
  actions: {
    async getClassesAsync({commit}, payload) {
        //调用api 的方法
      const res = await api.classes.get(payload);
      if (res.code) {
        console.log(res.data);
        commit("SET_CLASSES", res.data);
      }
    },
    async getClassesBySidAsync({commit}, payload){
      const res = await api.classes. getBySid(payload);
      if (res.code) {
        console.log(res.data);
        commit("SET_CLASSES", res.data);
      }
    }
  }
};